From 2b70724a0b4014e6ef14d0c5bbbdfef8cecb3d49 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Fri, 5 May 2006 12:10:16 +0000 Subject: [PATCH] * (bug 3309) Allow comments when undeleting pages * Clean up Special:Undelete a bit --- RELEASE-NOTES | 2 ++ includes/SpecialUndelete.php | 59 ++++++++++++++++++++++++------------ languages/Messages.php | 7 ++++- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ae829e02e0..54c3ae94ae 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -210,6 +210,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Changed default LocalSettings.php to append the previous include path when setting it * (bug 5837) Use "members" for the value descriptor in Special:Categories, Special:Wantedcategories and Special:Mostlinkedcategories. +* (bug 3309) Allow comments when undeleting pages +* Clean up Special:Undelete a bit == Compatibility == diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index b38206d077..8da70e0a6a 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -1,8 +1,11 @@ addEntry( 'restore', $this->title, $reason ); @@ -304,7 +309,7 @@ class PageArchive { */ class UndeleteForm { var $mAction, $mTarget, $mTimestamp, $mRestore, $mTargetObj; - var $mTargetTimestamp, $mAllowed; + var $mTargetTimestamp, $mAllowed, $mComment; function UndeleteForm( &$request, $par = "" ) { global $wgUser; @@ -316,6 +321,7 @@ class UndeleteForm { $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) ); $this->mRestore = $request->getCheck( 'restore' ) && $posted; $this->mPreview = $request->getCheck( 'preview' ) && $posted; + $this->mComment = $request->getText( 'wpComment' ); if( $par != "" ) { $this->mTarget = $par; @@ -471,17 +477,10 @@ class UndeleteForm { if ( $this->mAllowed ) { $titleObj = Title::makeTitle( NS_SPECIAL, "Undelete" ); - $action = $titleObj->escapeLocalURL( "action=submit" ); - $encTarget = htmlspecialchars( $this->mTarget ); - $button = htmlspecialchars( wfMsg("undeletebtn") ); - $token = htmlspecialchars( $wgUser->editToken() ); - - $wgOut->addHTML(" -
- - - - "); + $action = $titleObj->getLocalURL( "action=submit" ); + # Start the form here + $top = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $action ) ); + $wgOut->addHtml( $top ); } # Show relevant lines from the deletion log: @@ -493,9 +492,27 @@ class UndeleteForm { array( 'page' => $this->mTargetObj->getPrefixedText(), 'type' => 'delete' ) ) ) ); $logViewer->showList( $wgOut ); + + $wgOut->addHTML( "

" . htmlspecialchars( wfMsg( "history" ) ) . "

\n" ); + + if( $this->mAllowed ) { + # Brief explanation of how it all works + $wgOut->addHtml( '
' ); + #$wgOut->addWikiText( wfMsg( 'undeleteextrahelp' ) ); + # Format the user-visible controls (comment field, submission button) + # in a nice little table + $table .= ''; + $table .= ''; + $table .= ''; + $table .= ''; + $table .= '
' . wfMsgWikiHtml( 'undeleteextrahelp' ) . '
' . wfMsgHtml( 'undeletecomment' ) . '' . wfInput( 'wpComment', 50, $this->mComment ) . '
 '; + $table .= wfSubmitButton( wfMsg( 'undeletebtn' ), array( 'name' => 'restore' ) ); + $table .= wfElement( 'input', array( 'type' => 'reset', 'value' => wfMsg( 'undeletereset' ) ) ); + $table .= '
'; + $wgOut->addHtml( $table ); + } # The page's stored (deleted) history: - $wgOut->addHTML( "

" . htmlspecialchars( wfMsg( "history" ) ) . "

\n" ); $wgOut->addHTML(""); + if ( $this->mAllowed ) { - $wgOut->addHTML( "\n
" ); + # Slip in the hidden controls here + $misc = wfHidden( 'target', $this->mTarget ); + $misc .= wfHidden( 'wpEditToken', $wgUser->editToken() ); + $wgOut->addHtml( $misc ) . ''; } return true; @@ -536,7 +557,7 @@ class UndeleteForm { global $wgOut; if( !is_null( $this->mTargetObj ) ) { $archive = new PageArchive( $this->mTargetObj ); - if( $archive->undelete( $this->mTargetTimestamp ) ) { + if( $archive->undelete( $this->mTargetTimestamp, $this->mComment ) ) { $wgOut->addWikiText( wfMsg( "undeletedtext", $this->mTarget ) ); if (NS_IMAGE == $this->mTargetObj->getNamespace()) { diff --git a/languages/Messages.php b/languages/Messages.php index 1e2bd66be3..524e74fba1 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -1181,6 +1181,9 @@ page protection levels. Here are the current settings for the page $1 'View deleted pages', 'undeletepagetext' => 'The following pages have been deleted but are still in the archive and can be restored. The archive may be periodically cleaned out.', +'undeleteextrahelp' => "To restore the entire page, leave all checkboxes deselected and +click '''''Restore'''''. To perform a selective restoration, check the boxes corresponding to the +revisions to be restored, and click '''''Restore'''''.", 'undeletearticle' => 'Restore deleted page', 'undeleterevisions' => "$1 revisions archived", 'undeletehistory' => 'If you restore the page, all revisions will be restored to the history. @@ -1191,7 +1194,9 @@ will not be automatically replaced.', shown in the summary below, along with details of the users who had edited this page before deletion. The actual text of these deleted revisions is only available to administrators.', 'undeleterevision' => "Deleted revision as of $1", -'undeletebtn' => 'Restore!', +'undeletebtn' => 'Restore', +'undeletereset' => 'Reset', +'undeletecomment' => 'Comment:', 'undeletedarticle' => "restored \"[[$1]]\"", 'undeletedrevisions' => "$1 revisions restored", 'undeletedtext' => "[[:$1|$1]] has been successfully restored. -- 2.20.1